﻿package com.tudou.ad.view
{
    import com.tudou.ad.view.base.*;
    import com.tudou.home.consts.*;
    import com.tudou.utils.*;
    import flash.display.*;

    public class AdBackgroundView extends AdItemViewBase
    {

        public function AdBackgroundView()
        {
            return;
        }// end function

        private function initSpaceMask() : void
        {
            var _loc_1:DisplayObject = null;
            _loc_1 = RectDisplayUtil.getSprite(PlayerConsts.SKIN_WIDTH, 10, 0, 0);
            _loc_1.x = PlayerConsts.VIDEO_LEFT;
            _loc_1.y = 0;
            viewBox.addChild(_loc_1);
            return;
        }// end function

        override public function goTransform(param1:uint, param2:uint, param3:Boolean) : void
        {
            _isFullscreen = param3;
            if (frontAdSprite)
            {
                if (_isExpand || _isFullscreen)
                {
                    frontAdSprite.visible = false;
                }
                else
                {
                    frontAdSprite.visible = true;
                    frontAdSprite.setWidthHeight(param1, param2);
                }
            }
            return;
        }// end function

        override public function startAd() : void
        {
            if (!startAdCommon())
            {
                return;
            }
            showAd();
            frontAdSprite.visible = true;
            adShowStart();
            return;
        }// end function

        override public function initToShow() : void
        {
            if (!initToShowCommon())
            {
                return;
            }
            hasFront = adItemInfo.url ? (true) : (false);
            initFrontStuff();
            initSpaceMask();
            addToShowStuff();
            return;
        }// end function

        override public function clearAd() : void
        {
            _clearAd(true);
            return;
        }// end function

        protected function _clearAd(param1:Boolean) : void
        {
            if (!clearAdCommon())
            {
                return;
            }
            isSkip = param1;
            if (isSkip)
            {
                _adShowSkip();
            }
            hideAd();
            clearComps();
            countDownTime = 0;
            adItemInfo = null;
            adShowEnd();
            return;
        }// end function

        override protected function adClick(param1:String = null) : void
        {
            if (param1 == "")
            {
                openURL(adItemInfo.link);
            }
            _adClick(param1);
            return;
        }// end function

        override protected function adShowComplete() : void
        {
            if (!isSkip)
            {
                _adShowComplete();
            }
            _clearAd(isSkip);
            return;
        }// end function

        override protected function clearComps() : void
        {
            clearFrontStuff();
            clearCompsCommon();
            return;
        }// end function

    }
}
